{
 "cells": [
  {
   "cell_type": "code",
   "id": "initial_id",
   "metadata": {
    "collapsed": true,
    "ExecuteTime": {
     "end_time": "2025-11-17T08:21:07.832323Z",
     "start_time": "2025-11-17T08:21:07.434019Z"
    }
   },
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "\n",
    "date_ser =pd.Series([12,56,89,99,31])\n",
    "date_ser"
   ],
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0    12\n",
      "1    56\n",
      "2    89\n",
      "3    99\n",
      "4    31\n",
      "dtype: int64\n"
     ]
    }
   ],
   "execution_count": 1
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-11-17T08:21:34.461230Z",
     "start_time": "2025-11-17T08:21:34.448150Z"
    }
   },
   "cell_type": "code",
   "source": [
    "from pandas.tseries.offsets import*\n",
    "date_offset = Week(2) + Hour(10)\n",
    "pd.date_range('2023/1/1','2023/1/31',freq=date_offset)"
   ],
   "id": "6e56d27ba183bb0f",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "DatetimeIndex(['2023-01-01 00:00:00', '2023-01-15 10:00:00',\n",
       "               '2023-01-29 20:00:00'],\n",
       "              dtype='datetime64[ns]', freq='346h')"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 3
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-11-17T08:31:23.716927Z",
     "start_time": "2025-11-17T08:31:23.709775Z"
    }
   },
   "cell_type": "code",
   "source": [
    "period_index = pd.period_range('2023.1.8','2023.5.31',freq ='M')\n",
    "period_index"
   ],
   "id": "2c32aac340946433",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "PeriodIndex(['2023-01', '2023-02', '2023-03', '2023-04', '2023-05'], dtype='period[M]')"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 4
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-11-17T08:33:23.850577Z",
     "start_time": "2025-11-17T08:33:23.843462Z"
    }
   },
   "cell_type": "code",
   "source": [
    "str_list =['2021','2022','2023']\n",
    "pd.PeriodIndex(str_list,freq='Y-DEC')"
   ],
   "id": "9a8f7c5eb33f4a26",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "PeriodIndex(['2021', '2022', '2023'], dtype='period[Y-DEC]')"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 5
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-11-17T08:35:28.657225Z",
     "start_time": "2025-11-17T08:35:28.648491Z"
    }
   },
   "cell_type": "code",
   "source": [
    "period_ser = pd.Series(np.arange(5),period_index)\n",
    "period_ser"
   ],
   "id": "5641b3c9c6f09ca7",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2023-01    0\n",
       "2023-02    1\n",
       "2023-03    2\n",
       "2023-04    3\n",
       "2023-05    4\n",
       "Freq: M, dtype: int64"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 6
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
